import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { viteMockServe } from "vite-plugin-mock"
import autoImport from 'unplugin-auto-import/vite'
import Pages from "vite-plugin-pages";

import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'

import path from "path"
// https://vitejs.dev/config/
export default defineConfig({
	server: {
		open: true
	},
	plugins: [
		vue(),
		viteMockServe(),
		autoImport({
			imports: [
				'vue',
				'vue-router',
				{
					'vue': [
						'defineProps',
						'defineEmits',
						'defineExpose',
						'withDefaults'
					]
				},
				'pinia'
			],
			resolvers: [ElementPlusResolver()]
		}),
		Components({
			resolvers: [
			  ElementPlusResolver()
			],
		}),
		Pages({
		  dirs: "src/view", // 需要生成路由的文件目录，默认就是识别src下面的pages文件
		  exclude: ["**/components/*.vue"], // 排除在外的目录，即不将所有 components 目录下的 .vue 文件生成路由
		}),
		createSvgIconsPlugin({
			iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
        	symbolId: 'icon-[dir]-[name]',
		})
	],
	// base: "./",
	resolve: {
		// 配置路径别名
		alias: {
			'@': path.resolve(__dirname, './src'),
		},
	}
})
